<template>
    <span class="wy-tag" @click="tagClick(item)">
      {{item[labelField]}}
      <i v-if="showClose === true" class="el-icon-close" style="font-size: 12px;" @click="iconClick($event, item)"></i>
    </span>
</template>
<script>
  
  export default {
    name: "WYTag",
    data: function() {
      return {
        msg: ''
      }
    },
    methods: {
      tagClick: function(item) {
        this.$emit('tagClick', item);
      },
      iconClick: function(e, item) {
        e.stopPropagation();
        this.$emit('tagDelClick', item);
      }
    },
    props: {
      item: {
        type: Object,
        default: function() {
          return {}
        }
      },
      showClose: {
        type: Boolean,
        default: function() {
          return false
        }
      },
      labelField: {
        type: String,
        default: function() {
          return 'label';
        }
      }
    },
    mounted: function(){
      
    }
  }
  
</script>
<style scoped="scoped">
  .wy-tag {
    padding: 0 5px;
    display: inline-block;  border-radius: 4px;
    border: 1px solid rgba(32,160,255,.2);
    color: #20a0ff;
    min-width: 35px;
    text-align: center;
    height: 24px;
    box-sizing: border-box;
    line-height: 22px;
    margin-right: 3px;
    font-size: 12px;
    background-color: rgba(32,160,255,.1);
    white-space: nowrap;
  }
  .wy-tag:hover {
    cursor: pointer;
  }
</style>